package com.api.shopapi.mapper;

import com.api.shopapi.entity.GoodsColorRemark;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface GoodsColorRemarkMapper {

    @Insert("insert into goods_color_remark values " +
            "(#{goodsColorRemark.GoodsColorRemarkCode},#{goodsColorRemark.GoodsColorCode},#{goodsColorRemark.BusinessCode},#{goodsColorRemark.Name})")
    int insert(@Param("goodsColorRemark") GoodsColorRemark goodsColorRemark);

    @Delete("delete from goods_color_remark where GoodsColorRemarkCode=#{goodsColorRemarkCode}")
    int delete(@Param("goodsColorRemarkCode") String goodsColorRemarkCode);

    @Update("update goods_color_remark set GoodsColorCode=#{goodsColorRemark.GoodsColorCode},BusinessCode=#{goodsColorRemark.BusinessCode}," +
            "Name=#{goodsColorRemark.Name}")
    int update(@Param("goodsColorRemark") GoodsColorRemark goodsColorRemark);

    @Select("select * from goods_color_remark where GoodsColorRemarkCode=#{goodsColorRemarkCode} limit 1")
    GoodsColorRemark getByGoodsColorRemarkCode(@Param("goodsColorRemarkCode") String goodsColorRemarkCode);

    @Select("select * from goods_color_remark where BusinessCode=#{businessCode}")
    List<GoodsColorRemark> getList(@Param("businessCode") String businessCode);

    @Select("<script>" +
            "select * from goods_color_remark " +
            "where BusinessCode=#{businessCode} "+
            "<if test ='name !=null and name!=\"\" '>" +
            "and Name like concat('%',#{name},'%') " +
            "</if>" +
            "</script>")
    List<GoodsColorRemark> getPageList(@Param("name") String name,@Param("businessCode") String businessCode);
}
